package edu.ynu.se.xiecheng.achitectureclass.controller;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;
import edu.ynu.se.xiecheng.achitectureclass.service.UserService;

@RestController
@RequestMapping("/user")
public class UserController {

    @Autowired
    private UserService userService;

    // 登录接口
    @PostMapping("/login")
    public String login(@RequestParam String username, @RequestParam String password) {
        boolean loginSuccessful = userService.login(username, password);
        if (loginSuccessful) {
            return "登录成功";
        } else {
            return "用户名或密码错误";
        }
    }
}
